<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>xeokit Example</title>
    <link href="../css/pageStyle.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>
</head>
<body>
<input type="checkbox" id="info-button"/>
<label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label>
<canvas id="myCanvas"></canvas>
<div class="slideout-sidebar">
    <img class="info-icon" src="../../assets/images/gltf_logo.png"/>
    <h1>GLTFLoaderPlugin</h1>
    <h2>Physically-based rendering of a binary glTF test model</h2>
    <p>In this example, we're using a <a
            href="../../docs/class/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js~GLTFLoaderPlugin.html"
            target="_other">GLTFLoaderPlugin</a> to load the <a
            href="https://sketchfab.com/bimcc"
            target="_other">Vianney House</a> model from
        binary glTF (.glb).</p>
    <h3>Components used</h3>
    <ul>
        <li>
            <a href="../../docs/class/src/viewer/Viewer.js~Viewer.html"
               target="_other">Viewer</a>
        </li>
        <li>
            <a href="../../docs/class/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js~GLTFLoaderPlugin.html"
               target="_other">GLTFLoaderPlugin</a>
        </li>
    </ul>
    <h3>Assets</h3>
    <ul>
        <li>
            <a href="https://sketchfab.com/bimcc"
               target="_other">Model source</a>
        </li>
    </ul>
</div>
</body>
<script type="module">

    import {Viewer, GLTFLoaderPlugin, ReflectionMap, LightMap, sRGBEncoding} from "../../dist/xeokit-sdk.min.es.js";

    const viewer = new Viewer({
        canvasId: "myCanvas",
        transparent: true,
        pbrEnabled: true,
        colorTextureEnabled: true
    });

    viewer.scene.gammaInput = true;
    viewer.scene.gammaOutput = true;
    viewer.scene.gammaFactor = 2.2;

    viewer.camera.eye = [-2.56, 8.38, 8.27];
    viewer.camera.look = [13.44, 3.31, -14.83];
    viewer.camera.up = [0.10, 0.98, -0.14];

    viewer.cameraControl.doublePickFlyTo = false;

    // new ReflectionMap(viewer.scene, {
    //     src: [
    //         "../../assets/textures/reflect/Uffizi_Gallery/Uffizi_Gallery_Radiance_PX.png",
    //         "../../assets/textures/reflect/Uffizi_Gallery/Uffizi_Gallery_Radiance_NX.png",
    //         "../../assets/textures/reflect/Uffizi_Gallery/Uffizi_Gallery_Radiance_PY.png",
    //         "../../assets/textures/reflect/Uffizi_Gallery/Uffizi_Gallery_Radiance_NY.png",
    //         "../../assets/textures/reflect/Uffizi_Gallery/Uffizi_Gallery_Radiance_PZ.png",
    //         "../../assets/textures/reflect/Uffizi_Gallery/Uffizi_Gallery_Radiance_NZ.png"
    //     ],
    //     encoding: sRGBEncoding
    // });
    //
    // new LightMap(viewer.scene, {
    //     src: [
    //         "../../assets/textures/light/Uffizi_Gallery/Uffizi_Gallery_Irradiance_PX.png",
    //         "../../assets/textures/light/Uffizi_Gallery/Uffizi_Gallery_Irradiance_NX.png",
    //         "../../assets/textures/light/Uffizi_Gallery/Uffizi_Gallery_Irradiance_PY.png",
    //         "../../assets/textures/light/Uffizi_Gallery/Uffizi_Gallery_Irradiance_NY.png",
    //         "../../assets/textures/light/Uffizi_Gallery/Uffizi_Gallery_Irradiance_PZ.png",
    //         "../../assets/textures/light/Uffizi_Gallery/Uffizi_Gallery_Irradiance_NZ.png"
    //     ],
    //     encoding: sRGBEncoding
    // });

    const gltfLoader = new GLTFLoaderPlugin(viewer);

    const sceneModel = gltfLoader.load({
        id: "myModel",
        src: "../../assets/models/gltf/VianneyHouse2/glTF-Binary/VianneyHouse2.glb",
        edges: true,
        rotation: [-90, 0, 0]
    });

    sceneModel.on("loaded", () => {
        viewer.cameraFlight.jumpTo(sceneModel);
    });

    viewer.cameraControl.on("picked", function (e) {
        console.log(e.entity.id);
    })

    window.viewer = viewer;

</script>
</html>